import { withUser, json } from "@/lib/api"; import { getArenaShare, revokeArenaShare, shareArenaSession } from "@/lib/arena/service"; import { LIMITS } from "@/lib/rate-limit"; export const dynamic = "force-dynamic"; type P = { id: string }; /** GET /api/arena/:id/share → { share: { id, createdAt, viewCount } | null } */ export const GET = withUser
(async ({ user }, { id }) => json({ share: await getArenaShare(user.id, id) })); /** POST /api/arena/:id/share → { share } — creates (or refreshes) the public snapshot at /share/arena/:shareId. */ export const POST = withUser
(async ({ user }, { id }) => json({ share: await shareArenaSession(user.id, id) }, { status: 201 }), { limit: { ...LIMITS.share, key: "arena-share" } }); /** DELETE /api/arena/:id/share → { ok } — revokes every active link for the session. */ export const DELETE = withUser
(async ({ user }, { id }) => { await revokeArenaShare(user.id, id); return json({ ok: true }); });